{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\MSCI.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 7 Nov 2025, 14:58:54
{txt}
{com}. /* Define local and global variables */
> 
> local directory = "../../Data_nonpublic/MSCI";
{txt}
{com}. do global;
{txt}
{com}. /* global.do (STATA)
>         Define global variables in "Data".
>         by Ralph Koijen & Motohiro Yogo */
. 
. #delimit ;
{txt}delimiter now ;
{com}. clear all;
{res}{txt}
{com}. global year_min = 2003;
{txt}
{com}. global year_max = 2020;
{txt}
{com}. global small = 5e-4;
{txt}
{com}.         /* Minimum reportable threshold for CPIS */

{txt}end of do-file

{com}. /* Step 1: Construct market value */
> 
> /* Load data */
> 
> import excel using "`directory'/MSCI MV PBV",
>         sheet("Market Value") cellra(B11) first clear;
{res}{text}(50 vars, 348 obs)

{com}. /* Rename variables */
> 
> foreach var of varlist Argentina-UnitedStates {c -(};
{txt}  2{com}.         rename `var' market`var';
{txt}  3{com}. {c )-};
{res}{txt}
{com}. /* Reshape in long format */
> 
> reshape long market, i(DATE) j(Name) string;
{txt}(j = Argentina Australia Austria Belgium Brazil Canada Chile China Colombia CzechRepublic Denmark Egypt Finland France Germany Greece HongKong Hungary India Indonesia Ireland Israel Italy Japan Jordan Malaysia Mexico Morocco Netherlands NewZealand Norway Pakistan Peru Philippines Poland Portugal Russia Singapore SouthAfrica SouthKorea Spain SriLanka Sweden Switzerland Taiwan Thailand Turkey UnitedKingdom UnitedStates)

Data{col 36}Wide{col 43}->{col 48}Long
{hline 77}
Number of observations     {res}         348   {txt}->   {res}17,052      
{txt}Number of variables        {res}          50   {txt}->   {res}3           
{txt}j variable (49 values)                    ->   {res}Name
{txt}xij variables:
{res}marketArgentina marketAustralia ... marketUnitedStates{txt}->{res}market
{txt}{hline 77}

{com}. /* Convert to US$ billion */
> 
> replace market = market/1e3;
{txt}(16,361 real changes made)

{com}. /* Save data */
> 
> tempfile market;
{txt}
{com}. save `market';
{txt}{p 0 4 2}
file {bf}
C:\Users\myogo\AppData\Local\Temp\ST_8970_000001.tmp{rm}
saved
as .dta format
{p_end}

{com}. /* Step 2: Construct market-to-book equity */
> 
> /* Load data */
> 
> import excel using "`directory'/MSCI MV PBV",
>         sheet("Price to BV") cellra(B11) first clear;
{res}{text}(50 vars, 565 obs)

{com}. /* Rename variables */
> 
> foreach var of varlist Argentina-UnitedStates {c -(};
{txt}  2{com}.         rename `var' pbv`var';
{txt}  3{com}. {c )-};
{res}{txt}
{com}. /* Reshape in long format */
> 
> reshape long pbv, i(DATE) j(Name) string;
{txt}(j = Argentina Australia Austria Belgium Brazil Canada Chile China Colombia CzechRepublic Denmark Egypt Finland France Germany Greece HongKong Hungary India Indonesia Ireland Israel Italy Japan Jordan Malaysia Mexico Morocco Netherlands NewZealand Norway Pakistan Peru Philippines Poland Portugal Russia Singapore SouthAfrica SouthKorea Spain SriLanka Sweden Switzerland Taiwan Thailand Turkey UnitedKingdom UnitedStates)

Data{col 36}Wide{col 43}->{col 48}Long
{hline 77}
Number of observations     {res}         565   {txt}->   {res}27,685      
{txt}Number of variables        {res}          50   {txt}->   {res}3           
{txt}j variable (49 values)                    ->   {res}Name
{txt}xij variables:
{res}pbvArgentina pbvAustralia ... pbvUnitedStates{txt}->{res}pbv
{txt}{hline 77}

{com}. /* Step 3: Merge market value and market-to-book equity */
> 
> merge 1:1 DATE Name using `market',
>         nogen keep(master match);
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}          10,633
{txt}{col 9}from master{col 30}{res}          10,633{txt}  
{col 9}from using{col 30}{res}               0{txt}  

{col 5}Matched{col 30}{res}          17,052{txt}  
{col 5}{hline 41}

{com}. /* Fix variables */
> 
> replace Name = regexr(Name,regexs(0),regexs(1)+" "+regexs(2))
>         if regexm(Name,"([a-z])([A-Z])");
{txt}variable {bf}{res}Name{sf}{txt} was {bf}{res}str13{sf}{txt} now {bf}{res}str14{sf}
{txt}(4,520 real changes made)

{com}. /* Merge country code */
> 
> merge m:1 Name using Countries,
>         keepusing(country)
>         nogen keep(match);
{res}{txt}{p 0 7 2}
(variable
{bf:Name} was {bf:str14}, now {bf:str32} to accommodate using data's values)
{p_end}

{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}               0
{txt}{col 5}Matched{col 30}{res}          27,685{txt}  
{col 5}{hline 41}

{com}. drop Name;
{txt}
{com}. /* Construct variables */
> 
> gen int year = year(DATE);
{txt}
{com}. /* Keep year-end data */
> 
> sort year country DATE;
{txt}
{com}. by year country: keep if _n==_N;
{txt}(25,333 observations deleted)

{com}. drop DATE;
{txt}
{com}. /* Sample criteria */
> 
> keep if inrange(year,$year_min,$year_max);
{txt}(1,470 observations deleted)

{com}. /* Label variables */
> 
> order year country;
{txt}
{com}. label var year          "Year";
{txt}
{com}. label var pbv           "Market-to-book equity";
{txt}
{com}. label var market        "Market value (US$ billion)";
{txt}
{com}. /* Save data */
> 
> sort year country;
{txt}
{com}. save MSCI, replace;
{txt}{p 0 4 2}
file {bf}
MSCI.dta{rm}
saved
{p_end}

{com}. log close;
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\MSCI.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 7 Nov 2025, 14:58:57
{txt}{.-}
{smcl}
{txt}{sf}{ul off}